﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Doan_ver1
{
    public partial class WebForm3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        public string connection()
        {
           return Provider.connectionString();
        }
        protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
        {
            
           // String connectionString = "Data Source=RICARDOQUI-PC;Initial Catalog=NGANHANG;Integrated Security=SSPI";
            SQLNganHangDataContext data = new SQLNganHangDataContext(connection());
            if (data.TaiKhoans.Where(user => user.TenDangNhap == Login1.UserName && user.PassWord == Login1.Password).Count() == 1)
            {
                e.Authenticated = true;
            }
            else
            {
                e.Authenticated = false;
            }
        }

        protected void Login1_LoggedIn(object sender, EventArgs e)
        {
            Session["khachhang"] = Login1.UserName;
            Session.Timeout = 2800;
            Response.Redirect("Home.aspx");
        }

        protected void Login1_LoggingIn(object sender, LoginCancelEventArgs e)
        {

        }
    }
}